﻿Imports System
Imports System.Workflow.ComponentModel
Imports System.Workflow.ComponentModel.Compiler

Namespace System.Workflow.Activities
    Friend NotInheritable Class ParallelValidator
        Inherits CompositeActivityValidator
        ' Methods
        Public Overrides Function Validate(ByVal manager As ValidationManager, ByVal obj As Object) As ValidationErrorCollection
            Dim errors As ValidationErrorCollection = MyBase.Validate(manager, obj)
            Dim activity As ParallelActivity = [TryCast](obj,ParallelActivity)
            If (activity Is Nothing) Then
                Throw New ArgumentException(SR.GetString("Error_UnexpectedArgumentType", New Object() { GetType(ParallelActivity).FullName }), "obj")
            End If
            If (activity.EnabledActivities.Count < 2) Then
                errors.Add(New ValidationError(SR.GetString("Error_ParallelLessThanTwoChildren"), &H517))
            End If
            Dim flag As Boolean = False
            Dim activity2 As Activity
            For Each activity2 In activity.EnabledActivities
                If (Not activity2.GetType Is GetType(SequenceActivity)) Then
                    flag = True
                End If
            Next
            If flag Then
                errors.Add(New ValidationError(SR.GetString("Error_ParallelNotAllSequence"), &H518))
            End If
            Return errors
        End Function

    End Class
End Namespace

